// File generated from our OpenAPI spec
namespace Stripe
{
    using System;
    using System.Collections.Generic;
    using System.Net;
    using System.Net.Http;
    using System.Threading;
    using System.Threading.Tasks;

    public class InvoiceRenderingTemplateService : Service<InvoiceRenderingTemplate>,
        IListable<InvoiceRenderingTemplate, InvoiceRenderingTemplateListOptions>,
        IRetrievable<InvoiceRenderingTemplate, InvoiceRenderingTemplateGetOptions>
    {
        public InvoiceRenderingTemplateService()
        {
        }

        internal InvoiceRenderingTemplateService(ApiRequestor requestor)
            : base(requestor)
        {
        }

        public InvoiceRenderingTemplateService(IStripeClient client)
            : base(client)
        {
        }

        /// <summary>
        /// <p>Updates the status of an invoice rendering template to ‘archived’ so no new Stripe
        /// objects (customers, invoices, etc.) can reference it. The template can also no longer be
        /// updated. However, if the template is already set on a Stripe object, it will continue to
        /// be applied on invoices generated by it.</p>.
        /// </summary>
        public virtual InvoiceRenderingTemplate Archive(string id, InvoiceRenderingTemplateArchiveOptions options = null, RequestOptions requestOptions = null)
        {
            return this.Request<InvoiceRenderingTemplate>(BaseAddress.Api, HttpMethod.Post, $"/v1/invoice_rendering_templates/{WebUtility.UrlEncode(id)}/archive", options, requestOptions);
        }

        /// <summary>
        /// <p>Updates the status of an invoice rendering template to ‘archived’ so no new Stripe
        /// objects (customers, invoices, etc.) can reference it. The template can also no longer be
        /// updated. However, if the template is already set on a Stripe object, it will continue to
        /// be applied on invoices generated by it.</p>.
        /// </summary>
        public virtual Task<InvoiceRenderingTemplate> ArchiveAsync(string id, InvoiceRenderingTemplateArchiveOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
        {
            return this.RequestAsync<InvoiceRenderingTemplate>(BaseAddress.Api, HttpMethod.Post, $"/v1/invoice_rendering_templates/{WebUtility.UrlEncode(id)}/archive", options, requestOptions, cancellationToken);
        }

        /// <summary>
        /// <p>Retrieves an invoice rendering template with the given ID. It by default returns the
        /// latest version of the template. Optionally, specify a version to see previous
        /// versions.</p>.
        /// </summary>
        public virtual InvoiceRenderingTemplate Get(string id, InvoiceRenderingTemplateGetOptions options = null, RequestOptions requestOptions = null)
        {
            return this.Request<InvoiceRenderingTemplate>(BaseAddress.Api, HttpMethod.Get, $"/v1/invoice_rendering_templates/{WebUtility.UrlEncode(id)}", options, requestOptions);
        }

        /// <summary>
        /// <p>Retrieves an invoice rendering template with the given ID. It by default returns the
        /// latest version of the template. Optionally, specify a version to see previous
        /// versions.</p>.
        /// </summary>
        public virtual Task<InvoiceRenderingTemplate> GetAsync(string id, InvoiceRenderingTemplateGetOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
        {
            return this.RequestAsync<InvoiceRenderingTemplate>(BaseAddress.Api, HttpMethod.Get, $"/v1/invoice_rendering_templates/{WebUtility.UrlEncode(id)}", options, requestOptions, cancellationToken);
        }

        /// <summary>
        /// <p>List all templates, ordered by creation date, with the most recently created template
        /// appearing first.</p>.
        /// </summary>
        public virtual StripeList<InvoiceRenderingTemplate> List(InvoiceRenderingTemplateListOptions options = null, RequestOptions requestOptions = null)
        {
            return this.Request<StripeList<InvoiceRenderingTemplate>>(BaseAddress.Api, HttpMethod.Get, $"/v1/invoice_rendering_templates", options, requestOptions);
        }

        /// <summary>
        /// <p>List all templates, ordered by creation date, with the most recently created template
        /// appearing first.</p>.
        /// </summary>
        public virtual Task<StripeList<InvoiceRenderingTemplate>> ListAsync(InvoiceRenderingTemplateListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
        {
            return this.RequestAsync<StripeList<InvoiceRenderingTemplate>>(BaseAddress.Api, HttpMethod.Get, $"/v1/invoice_rendering_templates", options, requestOptions, cancellationToken);
        }

        /// <summary>
        /// <p>List all templates, ordered by creation date, with the most recently created template
        /// appearing first.</p>.
        /// </summary>
        public virtual IEnumerable<InvoiceRenderingTemplate> ListAutoPaging(InvoiceRenderingTemplateListOptions options = null, RequestOptions requestOptions = null)
        {
            return this.ListRequestAutoPaging<InvoiceRenderingTemplate>($"/v1/invoice_rendering_templates", options, requestOptions);
        }

        /// <summary>
        /// <p>List all templates, ordered by creation date, with the most recently created template
        /// appearing first.</p>.
        /// </summary>
        public virtual IAsyncEnumerable<InvoiceRenderingTemplate> ListAutoPagingAsync(InvoiceRenderingTemplateListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
        {
            return this.ListRequestAutoPagingAsync<InvoiceRenderingTemplate>($"/v1/invoice_rendering_templates", options, requestOptions, cancellationToken);
        }

        /// <summary>
        /// <p>Unarchive an invoice rendering template so it can be used on new Stripe objects
        /// again.</p>.
        /// </summary>
        public virtual InvoiceRenderingTemplate Unarchive(string id, InvoiceRenderingTemplateUnarchiveOptions options = null, RequestOptions requestOptions = null)
        {
            return this.Request<InvoiceRenderingTemplate>(BaseAddress.Api, HttpMethod.Post, $"/v1/invoice_rendering_templates/{WebUtility.UrlEncode(id)}/unarchive", options, requestOptions);
        }

        /// <summary>
        /// <p>Unarchive an invoice rendering template so it can be used on new Stripe objects
        /// again.</p>.
        /// </summary>
        public virtual Task<InvoiceRenderingTemplate> UnarchiveAsync(string id, InvoiceRenderingTemplateUnarchiveOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
        {
            return this.RequestAsync<InvoiceRenderingTemplate>(BaseAddress.Api, HttpMethod.Post, $"/v1/invoice_rendering_templates/{WebUtility.UrlEncode(id)}/unarchive", options, requestOptions, cancellationToken);
        }
    }
}
